package nowcoder;
/**
 * 45844 --两种排序方法
 * 链接：https://www.nowcoder.com/practice/839f681bf36c486fbcc5fcb977ffe432?tpId=85&&tqId=29844&rp=1&ru=/activity/oj&qru=/ta/2017test/question-ranking
 */
import java.util.*;
public class Day08_1 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        String[] arr = new String[n];
        for(int i = 0; i < arr.length; i++) {
            arr[i] = input.next();
        }

        // 开始遍历，看看到底是怎么排序的
        boolean isLengths = true;
        boolean isLexicographically = true;
        for(int i = 0; i < arr.length - 1; i++) {
            if(!isLengths && !isLexicographically){
                break;
            }
            // arr[i] 和 arr[i+1] 比较
            if(arr[i+1].length() < arr[i].length()){
                isLengths = false;
            }
            if(arr[i+1].compareTo(arr[i]) < 0) {
                isLexicographically = false;
            }
        }
        // 输出结果
        if(isLengths && isLexicographically){
            System.out.println("both");
        }else if(isLengths){
            System.out.println("lengths");
        }else if(isLexicographically){
            System.out.println("lexicographically");
        }else{
            System.out.println("none");
        }
    }
}
